﻿using LogSystem;
using NpcFramework;
using UnityEngine;

namespace Yoozoo.Gameplay.Liberty.AI.Utils
{
    public static class AIGraphUtils
    {
        public static LibertyAIManager AIManager;

        public static LibertyTrafficManager TrafficManager;

        public static PathPointData GetNextPoint(int pathId, int pointIndex,PathDirection pathDirection)
        {
            return TrafficManager.PathManager.GetNextPoint(pathId, pointIndex, pathDirection);
        }


        public static Vector3 GetNpcDestinationFormPoint(PathPointData point,Vector3 pos,float offsetFactor)
        {
            float b = Vector3.Dot((point.position - pos).normalized, point.forward.normalized);
            Vector3 offset = Vector3.zero;
            if (b < 0)
            {
                // 偏右
                offset = offsetFactor * point.right.normalized * point.width/2;
                offset.y = 0;
            }
            else
            {
                // 偏左
                offset = -offsetFactor * point.right.normalized * point.width/2;
                offset.y = 0;
            }
                    
            Vector3 destination = point.position + offset;
            return destination;
        }
        
        public static void OnNavTaskPosComplete()
        {
            
        }
        
    }
}